* Replication Syntax for: 
* "How "'Us' and 'Them' Relates to Voting Behavior - Social Structure, Social Identities, and Electoral Choice" 
* by Simon Bornschier, Silja Häusermann, Delia Zollinger and Céline Colombo
* 2021 Comparative Political Studies

* Analyses done with Stata/MP 16.1 for Mac

* Content of this syntax: 
* 1. Recoding 
* 2. Links between social structure -> social identities (Table 1, Appendix 1, Figure 2)
* 3. Links between social structure and social identities ---> party preference (Table 3, Figure 4, Figure 5, Appendix 2, Appendix 3)


***************************************************************
***************************************************************
**************** 1. Recoding **********************************
***************************************************************
***************************************************************

use ".../ReplicationData_Bornschieretal_CPS.dta"

* Party preference variable

tab E01
recode E01 (15 / 16 = .), gen(party)
tab party, missing
label values party E01

* party preference dummies
* left = SP, Grün, PdA, AL, Solidarités
* farright = SVP, EDU, SD
* center = FDP, CVP, BDP, GLP, CSP
* christdemo = CVP, CSP, BDP
* liberal = FDP, GLP

recode E01 (1 2 7 6 8= 1) (else = 0), gen(center)
recode E01 (4 13 14 = 1) (else = 0), gen(farright)
recode E01 (3 5 9 10 11 = 1) (else = 0), gen(left)
recode E01 (2 8 6 = 1) (else = 0), gen(christdemo)
recode E01 (1 7 = 1) (else =0), gen(liberal)

recode E01 (3 5 = 1)(1 2 7= 2)(4 = 3) (else = .), gen(leftcenterright)
tab leftcenterright, missing
label define leftcenterright 1 "left" 2 "center" ///
3 "farright"
label values leftcenterright leftcenterright


*  multinomial party preference variable "votechoice": 
recode E01 (3 5 9 10 11 = 1)(2 8 6 = 2)(1 7 = 3)(4 13 14 = 4)(16 = 5)(else = .), gen(votechoice)
tab votechoice, missing
label define votechoice 1 "left" 2 "christdemo" 3 "liberal" ///
4 "farright" 5"none"
label values votechoice votechoice

tab votechoice
tab party votechoice


recode E01 (1=1) (else=0), gen(FDP)
recode E01 (2=1) (else=0), gen(CVP)
recode E01 (2 6 =1) (else=0), gen(CVPBDP)
recode E01 (7=1) (else=0), gen(GLP)


*recode sociodemographics

* income
recode S25 (7 999 = .), gen(income)
tab income, missing
label values income S25
recode income (1 2 = 1) (3 4 = 2) (5 6 = 3), gen(income3)
label define income3 1 "< 70,000" 2 "70,000-120,000" ///
3 ">120,000"
label values income3 income3


* education and education level groups
gen edu=S4
tab edu, missing

* edugrp: Variante mit Matura = mittel
tab edugrp, missing

gen edulevel=.
replace edulevel=1 if edugrp=="low"
replace edulevel=2 if edugrp=="med"
replace edulevel=3 if edugrp=="high"
label define edulevel 1 "low" 2 "med" 3 "high"
label values edulevel edulevel
tab edulevel, m

* edugrp2: Variante mit Matura = hoch
gen edugrp2=edugrp
replace edugrp2 = "high" if edu==6
tab edugrp2, missing
label variable edugrp2 "Education level"


gen edulevel2=.
replace edulevel2=1 if edugrp2=="low"
replace edulevel2=2 if edugrp2=="med"
replace edulevel2=3 if edugrp2=="high"
label define edulevel2 1 "low" 2 "med" 3 "high"
label values edulevel2 edulevel2
tab edulevel2, m


* urban / rural
label variable Stadt_Land "Residence"

label define  Stadt_Land ///
1 "Urban" ///
2 "Rural"
label value Stadt_Land Stadt_Land
tab Stadt_Land


*residence: subjective & objective
recode S24 (999 = .), gen(residence_sub)
tab residence_sub, missing
label define residence_sub 1 "big city" 2 "agglomeration" 3 "small city" 4"town,rural"
label values residence_sub residence_sub
tab Stadt_Land, missing


gen sex=.
replace sex=0 if gender=="female"
replace sex=1 if gender=="male"
label define sex 0 "female" 1 "male" 
label values sex sex
tab sex, m


tab Age, missing
tab H_age, missing

*status
recode E03_1_E03_scale (999 = .), gen(status)
tab status, missing


* label class variables 
label variable class16_3d "Respondent's Oesch class position - 16 classes"
label define class16_3d ///
1 "Large employers" ///
2 "Self-employed professionals" ///
3 "Small business owners with employees" ///
4 "Small business owners without employees" ///
5 "Technical experts" ///
6 "Technicians" ///
7 "Skilled manual" ///
8 "Low-skilled manual" ///
9 "Higher-grade managers and administrators" ///
10 "Lower-grade managers and administrators" ///
11 "Skilled clerks" ///
12 "Unskilled clerks" ///
13 "Socio-cultural professionals" ///
14 "Socio-cultural semi-professionals" ///
15 "Skilled service" ///
16 "Low-skilled service"
label value class16_3d class16_3d
tab class16_3d


label variable class8_3d "Respondent's class position"
label define class8_3d ///
1 "Self-employed professionals and large employers" ///
2 "Small business owners" ///
3 "Technical (semi-)professionals" ///
4 "Production workers" ///
5 "(Associate) managers" ///
6 "Clerks" ///
7 "Socio-cultural (semi-)professionals" ///
8 "Service workers"
label value class8_3d class8_3d
tab class8_3d


label define class8_3dA ///
1 "EMP" ///
2 "SBO" ///
3 "TECH" ///
4 "PW" ///
5 "MNG" ///
6 "C" ///
7 "SCP" ///
8 "SW"
label value class8_3d class8_3dA
tab class8_3d


gen class7_3d = class8_3d
recode class7_3d (1=.)
tab class7_3d class8_3d

label variable class7_3d "Respondent's Oesch class position - 8 classes"
label define class7_3d ///
2 "SBO" ///
3 "Tech" ///
4 "PW" ///
5 "MNG" ///
6 "Clerks" ///
7 "SCP" ///
8 "SW"
label value class7_3d class7_3d
tab class7_3d


********** Rename identities *******************

gen  ID_university = C04_1_C04_scale
gen  ID_apprenticeship = C04_2_C04_scale
gen  ID_noapprenticeship = C04_3_C04_scale
gen  ID_wealthy = C04_4_C04_scale
gen  ID_middleclass = C04_5_C04_scale
gen  ID_modestmeans = C04_6_C04_scale
gen  ID_similarjob = C04_7_C04_scale
gen  ID_interpersonal = C04_8_C04_scale
gen  ID_product = C04_9_C04_scale
gen  ID_migrationbackground = C04_10_C04_scale
gen  ID_urban = C04_11_C04_scale
gen  ID_rural = C04_12_C04_scale
gen  ID_cosmopolitan = C04_13_C04_scale
gen  ID_men = C04_14_C04_scale
gen  ID_women = C04_15_C04_scale
gen  ID_cultured = C04_16_C04_scale
gen  ID_swiss = C04_17_C04_scale


recode  ID_university (999 = .)
recode  ID_apprenticeship (999 = .)
recode  ID_noapprenticeship (999 = .)
recode  ID_wealthy (999 = .)
recode  ID_middleclass (999 = .)
recode  ID_modestmeans (999 = .)
recode  ID_similarjob (999 = .)
recode  ID_interpersonal (999 = .)
recode  ID_product (999 = .)
recode  ID_migrationbackground (999 = .)
recode  ID_urban (999 = .)
recode  ID_rural (999 = .)
recode  ID_cosmopolitan (999 = .)
recode  ID_men (999 = .)
recode  ID_women (999 = .)
recode  ID_cultured (999 = .)
recode  ID_swiss (999 = .)

label define ID_cultured ///
1 "--" ///
2 "-" ///
3 "+" ///
4 "++"
label value ID_cultured ID_cultured
tab ID_cultured

label define ID_wealthy ///
1 "--" ///
2 "-" ///
3 "+" ///
4 "++"
label value ID_wealthy ID_wealthy
tab ID_wealthy

label define ID_swiss ///
1 "--" ///
2 "-" ///
3 "+" ///
4 "++"
label value ID_swiss ID_swiss
tab ID_swiss



*****************************************************************
*****************************************************************
* 2. Links between social structure -> social identities (Table 1, Appendix 1, Figure 2)
*****************************************************************
*****************************************************************


************************
************************
* Table 1
************************
************************


ologit ID_swiss ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_swiss1

ologit ID_swiss ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_swiss2

ologit ID_swiss i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_swiss3

ologit ID_swiss ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_swiss4

estout ID_swiss1 ID_swiss2 ID_swiss3 ID_swiss4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)


************************
************************
* Appendix 1
************************
************************


ologit ID_university ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_university1

ologit ID_university ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_university2

ologit ID_university i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_university3

ologit ID_university ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_university4

estout ID_university1 ID_university2 ID_university3 ID_university4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




ologit ID_apprenticeship ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_apprenticeship1

ologit ID_apprenticeship ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_apprenticeship2

ologit ID_apprenticeship i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_apprenticeship3

ologit ID_apprenticeship ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_apprenticeship4

estout ID_apprenticeship1 ID_apprenticeship2 ID_apprenticeship3 ID_apprenticeship4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




ologit ID_noapprenticeship ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_noapprenticeship1

ologit ID_noapprenticeship ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_noapprenticeship2

ologit ID_noapprenticeship i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_noapprenticeship3

ologit ID_noapprenticeship ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_noapprenticeship4

estout ID_noapprenticeship1 ID_noapprenticeship2 ID_noapprenticeship3 ID_noapprenticeship4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




ologit ID_wealthy ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_wealthy1

ologit ID_wealthy ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_wealthy2

ologit ID_wealthy i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_wealthy3

ologit ID_wealthy ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_wealthy4


estout ID_wealthy1 ID_wealthy2 ID_wealthy3 ID_wealthy4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)





ologit ID_middleclass ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_middleclass1

ologit ID_middleclass ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_middleclass2

ologit ID_middleclass i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_middleclass3

ologit ID_middleclass ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_middleclass4

estout ID_middleclass1 ID_middleclass2 ID_middleclass3 ID_middleclass4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)





ologit ID_modestmeans ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_modestmeans1

ologit ID_modestmeans ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_modestmeans2

ologit ID_modestmeans i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_modestmeans3

ologit ID_modestmeans ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_modestmeans4

estout ID_modestmeans1 ID_modestmeans2 ID_modestmeans3 ID_modestmeans4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




ologit ID_similarjob ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_similarjob1

ologit ID_similarjob ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_similarjob2

ologit ID_similarjob i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_similarjob3

ologit ID_similarjob ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_similarjob4

estout ID_similarjob1 ID_similarjob2 ID_similarjob3 ID_similarjob4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)





ologit ID_interpersonal ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_interpersonal1

ologit ID_interpersonal ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_interpersonal2

ologit ID_interpersonal i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_interpersonal3

ologit ID_interpersonal ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_interpersonal4

estout ID_interpersonal1 ID_interpersonal2 ID_interpersonal3 ID_interpersonal4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)






ologit ID_product ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_product1

ologit ID_product ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_product2

ologit ID_product i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_product3

ologit ID_product ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_product4

estout ID_product1 ID_product2 ID_product3 ID_product4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




ologit ID_migrationbackground ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_migrationbackground1

ologit ID_migrationbackground ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_migrationbackground2

ologit ID_migrationbackground i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_migrationbackground3

ologit ID_migrationbackground ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_migrationbackground4

estout ID_migrationbackground1 ID_migrationbackground2 ID_migrationbackground3 ID_migrationbackground4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




ologit ID_urban ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_urban1

ologit ID_urban ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_urban2

ologit ID_urban i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_urban3

ologit ID_urban ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_urban4

estout ID_urban1 ID_urban2 ID_urban3 ID_urban4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




ologit ID_rural ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_rural1

ologit ID_rural ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_rural2

ologit ID_rural i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_rural3

ologit ID_rural ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_rural4

estout ID_rural1 ID_rural2 ID_rural3 ID_rural4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




ologit ID_cosmopolitan ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_cosmopolitan1

ologit ID_cosmopolitan ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_cosmopolitan2

ologit ID_cosmopolitan i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_cosmopolitan3

ologit ID_cosmopolitan ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_cosmopolitan4

estout ID_cosmopolitan1 ID_cosmopolitan2 ID_cosmopolitan3 ID_cosmopolitan4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




ologit ID_men ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_men1

ologit ID_men ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_men2

ologit ID_men i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_men3

ologit ID_men ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_men4

estout ID_men1 ID_men2 ID_men3 ID_men4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




ologit ID_women ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_women1

ologit ID_women ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_women2

ologit ID_women i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_women3

ologit ID_women ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_women4

estout ID_women1 ID_women2 ID_women3 ID_women4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)





ologit ID_cultured ib(2).edulevel2 i.H_age i.sex [iweight=rake]
estimates store ID_cultured1

ologit ID_cultured ib(5).class7_3d i.H_age i.sex [iweight=rake]
estimates store ID_cultured2

ologit ID_cultured i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_cultured3

ologit ID_cultured ib(2).edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex [iweight=rake]
estimates store ID_cultured4

estout ID_cultured1 ID_cultured2 ID_cultured3 ID_cultured4, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats(r2_p bic N)




************************
************************
* Figure 2
************************
************************


set scheme s1mono

estimates restore ID_apprenticeship1
margins i.edulevel2, predict(outcome(4)) atmeans
marginsplot, recast(scatter) xtitle("") xscale(range(0.5 3.5)) yscale(range(0 0.8)) ylabel(0 (.1) .8) title("Apprenticeship degree (education level)") saving(ID_apprenticeship1, replace)

estimates restore ID_swiss1
margins i.edulevel2, predict(outcome(4)) atmeans
marginsplot, recast(scatter) xtitle("") xscale(range(0.5 3.5)) yscale(range(0 0.8)) ylabel(0 (.1) .8) title("Swiss (education level)") saving(ID_swiss1, replace)

estimates restore ID_product2
margins i.class7_3d, predict(outcome(4)) atmeans
marginsplot, recast(scatter) xtitle("") xscale(range(1.5 4)) yscale(range(0 0.8)) ylabel(0 (.1) .8) title("Manufacturing product (class)") saving(ID_product2, replace)

estimates restore ID_swiss2
margins i.class7_3d, predict(outcome(4)) atmeans
marginsplot, recast(scatter) xtitle("") xscale(range(1.5 4)) yscale(range(0 0.8)) ylabel(0 (.1) .8) title("Swiss (class)") saving(ID_swiss2, replace)

estimates restore ID_rural3
margins i.Stadt_Land, predict(outcome(4)) atmeans
marginsplot, recast(scatter) xtitle("") xscale(range(0.5 2.5)) yscale(range(0 0.8)) ylabel(0 (.1) .8) title("Rural (residence)") saving(ID_rural3, replace)

estimates restore ID_swiss3
margins i.Stadt_Land, predict(outcome(4)) atmeans
marginsplot, recast(scatter) xtitle("") xscale(range(0.5 2.5)) yscale(range(0 0.8)) ylabel(0 (.1) .8) title("Swiss (residence)") saving(ID_swiss3, replace)

graph combine ID_apprenticeship1.gph ID_swiss1.gph ///
ID_product2.gph ID_swiss2.gph ID_rural3.gph ID_swiss3.gph, cols(2)





*****************************************************************
*****************************************************************
* 3. Links between social structure and social identities ---> party preference (Table 3, Figure 4, Figure 5)
*****************************************************************
*****************************************************************



****************************
****************************
* Table 3
****************************
****************************


logit left ib(2).edulevel2 ib(8).class7_3d i.Stadt_Land i.H_age i.sex if votechoice!=. [iweight=rake]
estimates store left1

logit left ib(2).edulevel2 ib(8).class7_3d i.Stadt_Land i.H_age i.sex ///
ID_cosmopolitan ID_cultured ID_urban ///
ID_rural ID_swiss ID_wealthy if votechoice!=. [iweight=rake]
estimates store left2

logit farright ib(2).edulevel2 ib(8).class7_3d i.Stadt_Land i.H_age i.sex if votechoice!=. [iweight=rake]
estimates store farright1

logit farright ib(2).edulevel2 ib(8).class7_3d i.Stadt_Land i.H_age i.sex ///
ID_swiss ID_rural ID_product ///
ID_cosmopolitan ID_migrationbackground ID_cultured if votechoice!=. [iweight=rake]
estimates store farright2

estout left1 left2 farright1 farright2, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats (r2_p bic N)



******************
******************
* FIGURE 4
******************
******************

logit left ib(5).class7_3d i.edulevel2 i.Stadt_Land i.H_age i.sex ///
i.ID_cosmopolitan i.ID_cultured i.ID_urban ///
i.ID_rural i.ID_swiss i.ID_wealthy if votechoice!=. [iweight=rake]
estimates store left2

margins i.ID_cultured, atmeans
marginsplot, recast(scatter) xtitle("closeness to culturally interested people") xscale(range(0.5 4.5)) yscale(range(0 0.5)) ylabel(0 (.1) .5) title("") saving(left2, replace)

margins i.ID_wealthy, atmeans
marginsplot, recast(scatter) xtitle("closeness to wealthy people") xscale(range(0.5 4.5)) yscale(range(0 0.5)) ylabel(0 (.1) .5) title("") saving(left6, replace)

margins i.class7_3d, atmeans
marginsplot, recast(scatter) xtitle ("class") xscale(range(1.5 5)) yscale(range(0 0.5)) ylabel(0 (.1) .5) title("") saving(left7, replace)

graph combine left7.gph left2.gph left6.gph, cols(2)



******************
******************
* FIGURE 5
******************
******************


logit farright ib(5).class7_3d i.edulevel2 i.Stadt_Land i.H_age i.sex ///
i.ID_swiss i.ID_rural i.ID_product ///
i.ID_cosmopolitan i.ID_migrationbackground i.ID_cultured if votechoice!=. [iweight=rake]
estimates store farright2

estimates restore farright2

margins i.edulevel2, atmeans
marginsplot, recast(scatter) xtitle("education level") xscale(range(0.5 3.5)) yscale(range(0 0.7)) ylabel(0 (.1) .7) title("") saving(farright8, replace)

margins i.ID_swiss, atmeans
marginsplot, recast(scatter) xtitle("closeness to Swiss people") xscale(range(0.5 4.5)) yscale(range(0 0.7)) ylabel(0 (.1) .7) title("") saving(farright1, replace)

margins i.ID_cultured, atmeans
marginsplot, recast(scatter) xtitle("closeness to culturally interested people") xscale(range(0.5 4.5)) yscale(range(0 0.7)) ylabel(0 (.1) .7) title("") saving(farright6, replace)

graph combine farright8.gph farright1.gph farright6.gph, cols(2)



****************************
****************************
*  Appendix 2
****************************
****************************


foreach var of varlist C01_1_C01_scale - C01_13_C01_scale {
  ologit `var' i.leftcenterright
}

foreach var of varlist C04_1_C04_scale - C04_17_C04_scale {
  ologit `var' i.leftcenterright
}



****************************
****************************
*  Appendix 3
****************************
****************************

logit center i.edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex if votechoice!=. [iweight=rake]
estimates store center1

logit center i.edulevel2 ib(5).class7_3d i.Stadt_Land i.H_age i.sex ///
ID_university ID_wealthy ID_cosmopolitan ///
ID_modestmeans ID_noapprenticeship ID_product if votechoice!=. [iweight=rake]
estimates store center2

estout center1 center2, cells(b(star fmt(%9.3f)) t(par fmt(%9.2f))) ///
style(fixed) starlevels(* 0.05 ** 0.01 *** 0.001) stats (r2_p bic N)
